package com.time.hellotime.components.discovery;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.time.hellotime.R;
import com.time.hellotime.base.BaseFragment;
import com.time.hellotime.common.event.BaseEvent;

import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;

/**
 * Created by Bing on 2017/12/7.
 * E-mail is tx16bing@163.com
 */

public abstract class BaseDisFragment extends BaseFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        EventBus.getDefault().register(this);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    public void refreshData() {
    }

    @Subscribe
    public void onEventMainThread(BaseEvent event) {
        if (TextUtils.isEmpty(event.getBaseType())) {
            return;
        }
        if (TextUtils.equals(event.getBaseType(), getString(R.string.discovery_location_sc))) {
            refreshData();
        } else {
            return;
        }
    }

    @Override
    public void onDestroyView() {
        EventBus.getDefault().unregister(this);
        super.onDestroyView();
    }
}
